/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.slogger.listener;

import com.hyts.slogger.reactive.bean.FileLoggerEvent;
import com.hyts.threads.core.ScheduleThreadManager;
import com.hyts.threads.service.ThreadPoolService;
import lombok.AllArgsConstructor;

import java.io.File;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

/**
 * @project-name:coffice-toolbox
 * @package-name:com.hyts.slogger.listener
 * @author:LiBo/Alex
 * @create-date:2019-08-07 9:28
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description:
 */
@AllArgsConstructor
public class LogFileOffsetListener {

    /**
     * file logger event 日志对象服务
     */
    private FileLoggerEvent fileLoggerEvent;

    /**
     * 初始化延迟事件time对象
     */
    private Long initializeDelayTime;

    /**
     * 循环操作初始化操作事件
     */
    private Long repeatDelayTime;


    /**
     * FileLoggerEvent
     */
    public void start(){
        //判断校验对象是否为空!
        Objects.requireNonNull(fileLoggerEvent,"传入的File-Logger事件对象");
        ScheduleThreadManager.getInstance(true).createScheduleThread(initializeDelayTime,repeatDelayTime, TimeUnit.SECONDS,new ThreadPoolService<FileLoggerEvent>() {

            @Override
            public Object execute(FileLoggerEvent param) {
                return null;
            }

            @Override
            public Object execute() {
                String logFullPath = fileLoggerEvent.getLoggerPath()+ File.separator+fileLoggerEvent.getLoggerName();
                System.out.println(logFullPath);
                return null;
            }

            @Override
            public Object before(FileLoggerEvent param) {
                return null;
            }

            @Override
            public Object before() {
                return null;
            }

            @Override
            public Object after(FileLoggerEvent param) {
                return null;
            }

            @Override
            public Object after() {
                return null;
            }

            @Override
            public Object end(FileLoggerEvent param) {
                return null;
            }

            @Override
            public Object end() {
                return null;
            }
        });
    }
}
